package com.ler.pai.controller;


import com.ler.pai.service.MusicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 网易云 歌曲信息 前端控制器
 * </p>
 *
 * @author lww
 * @since 2019-12-29
 */
@Api(value = "/music", description = "网易云音乐 歌曲信息")
@RestController
@RequestMapping("/music")
@Slf4j
public class MusicController {

	@Resource
	private MusicService musicService;

	@ApiOperation("网易云音乐 获取歌曲评论")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "url", value = "歌曲分享链接", required = true),
	})
	@PostMapping("/comment")
	public String getComment(String url) {
		log.info("MusicController_getComment_url:{}", url);
		Assert.isTrue(StringUtils.isNotBlank(url), "参数错误，歌曲链接为空！");
		String comment = musicService.getComment(url);
		return comment;
	}

}
